<template>
  <div>
    我在这里抓所有数据
    <row>
      <coll>
        <mt-button type="primary" size="large">发送</mt-button>
      </coll>
      <coll>
        <mt-button type="danger" size="large" @click="closeConnect">关闭</mt-button>
      </coll>
      <coll>
        <mt-button type="danger" size="large" @click="reConnect">重连</mt-button>
      </coll>
    </row>
  </div>
</template>
<style lang="scss" scoped>

</style>
<script>
  import io from 'socket.io-client';
  import {mapState, mapGetters, mapActions} from 'vuex';
  import { talkUd } from 'store/modules/types';
  import Storage from 'util/lib/storage';
  export default{
    name: 'Talk',
    data(){
      return{

      }
    },
    components:{

    },
    computed:{
      ...mapGetters({
        "talkDetail": "c_talkDetail"
      })
    },

    methods: {
      ...mapActions({
        "getSocket": talkUd.A.GET_SOCKET
      }),
      closeConnect() {
        console.log('断开连接');
        this.talkDetail.socket.disconnect();
      },
      reConnect() {
        console.log('重新连接');
        this.talkDetail.socket.getSocket();
      }
    },
    created(){

    },
    mounted(){
      const obj = {
        name: "chern1992",
        roomid:"room1",
        src:"./static/img/3.jpg"
      }
      this.talkDetail.socket.emit('login', obj)
      this.talkDetail.socket.on("message", function(obj) {
        console.log(obj)
      })

      this.talkDetail.socket.emit("message", {msg: '对了'})

    }
  }
</script>
